/*
 * Generated via the com.flca generator
 */
package com.logica.hackthon.service;

import com.flca.base.ExternalServiceBase;
import com.flca.frw.context.FlcaContext;
import com.flca.frw.context.FlcaCtx;
import com.flca.frw.log.ILog;
import com.flca.frw.log.LogHelper;
import com.google.inject.Inject;
import com.logica.hackthon.dto.PositionDto;
import com.logica.hackthon.dto.TestMsgDto;
import com.logica.hackthon.entity.Player;
import com.logica.hackthon.service.intf.HackThonServiceIntf;
/**
 * @todo add comment for javadoc
 *
 * @author robin
 * @version $Id: ServiceClass.javajet,v 1.3 may 2008 robin bakkerus Exp $
 * @generated
 */
public class HackThonService extends ExternalServiceBase implements IHackThonService
{
	@Inject private HackThonServiceIntf service;
	protected ILog getLogger() {
		return LogHelper.getLogger(HackThonService.class);
	}
		
	/**
	 * @todo add comment for javadoc
	 * @generated
	 */
	public Player register(Player aPlayer, FlcaContext context) throws Exception 
	{
		stopwatch = logStart("starting register", context);
		FlcaCtx ctx = null;
		try {
			ctx = makeFlcaCtx(context, "register");
			checkInRole(ctx);
			startTransaction(ctx);
			Player result = service.register(aPlayer);
			commit(ctx);
			logFinish(stopwatch, "finished register", context);
			return result;
		} catch (Throwable t) {
			handleError(t, ctx);
			throw new Exception(t);
		} finally {
			cleanupCtx(ctx);
		}
	}	
	/**
	 * @todo add comment for javadoc
	 * @generated
	 */
	public Player findPlayer(String aEmail, FlcaContext context) throws Exception {
		logStart("starting findPlayer", context);
		FlcaCtx ctx = null;
		try {
			ctx = makeFlcaCtx(context, "findPlayer");
			checkInRole(ctx);
			startTransaction(ctx);
			Player result = service.findPlayer(aEmail);
			commit(ctx);
			logFinish(stopwatch, "finished findPlayer", context);
			return result;
		} catch (Throwable t) {
			handleError(t, ctx);
			throw new Exception(t);
		} finally {
			cleanupCtx(ctx);
		}
	}	
	/**
	 * @todo add comment for javadoc
	 * @generated
	 */
	public Long addPosition(PositionDto aPosition, FlcaContext context) throws Exception {
		logStart("starting addPosition", context);
		FlcaCtx ctx = null;
		try {
			ctx = makeFlcaCtx(context, "addPosition");
			checkInRole(ctx);
			startTransaction(ctx);
			Long result = service.addPosition(aPosition);
			commit(ctx);
			logFinish(stopwatch, "finished addPosition", context);
			return result;
		} catch (Throwable t) {
			handleError(t, ctx);
			throw new Exception(t);
		} finally {
			cleanupCtx(ctx);
		}
	}	
	/**
	 * @todo add comment for javadoc
	 * @generated
	 */
	public TestMsgDto getMessage(Long aGameId, FlcaContext context) throws Exception {
		logStart("starting getMessage", context);
		FlcaCtx ctx = null;
		try {
			ctx = makeFlcaCtx(context, "getMessage");
			checkInRole(ctx);
			startTransaction(ctx);
			TestMsgDto result = service.getMessage(aGameId);
			commit(ctx);
			logFinish(stopwatch, "finished getMessage", context);
			return result;
		} catch (Throwable t) {
			handleError(t, ctx);
			throw new Exception(t);
		} finally {
			cleanupCtx(ctx);
		}
	}
}
